<?php
/**
 * @ Fmash Top System
 * @ version: 3.0
 * @ author: i.coffee.smile@mail.com
 * @ date:2011-1-27
 * @ file:show.php $9
 */
 
include_once 'class_mysql.php';
include_once 'function.php';
include_once 'function_fav.php';
include_once 'admin.php';

$sid = incheck($_GET['id']);
$uid = incheck($_COOKIE['UID']);
$username = incheck($_COOKIE['Uname']);
include_once 'update_fav.php';

if(isset($sid)){
	$favnum = how_many_fav($sid);
	$update = "UPDATE `$top_man_fav` SET `favnum` = '$favnum' WHERE `sid` = $sid ";
	mysql_query($update);
	mysql_query("UPDATE `$top_man` SET `hearts` = '$favnum' WHERE `sid` = $sid ");
	$getShowinfo = "SELECT `sid`,`name`,`show`,`grade`,`branch`,`dateline`,`hearts`,`win`,`lose`,`winper` FROM `$top_man` WHERE `sid` = '$sid';";
	$getshows = mysql_query($getShowinfo);
	$info = mysql_fetch_row($getshows);
	$name = $info[1];
	$show = $info[2];
	$grade = $info[3];
	$branch = $info[4];
	$dateline = $info[5];
	$hearts = $info[6];
	$win = $info[7];
	$lose = $info[8];
	$winper = $info[9];
}

$url = en_now_url();

$updown = mysql_query("SELECT `up`,`down` FROM `$top_man` WHERE `sid`='$sid'");
$ud = mysql_fetch_row($updown);
$up = $ud[0];
$down = $ud[1];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
    
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title><?php echo $name;?> 的个人中心 - 吉首大学网络社区</title>
        <link href="style/mainv.css" media="screen" rel="stylesheet"type="text/css" />
        <link href="style/stylev.css" media="screen" rel="stylesheet"type="text/css" />
        <style type="text/css">
		img { max-width:140px; }
		img {width:expression(this.width>140?"140px":this.width+"px");}
		</style>
        <link type="image/x-icon" rel="shortcut icon" href="favicon.ico"/>
    </head>
    
  <body>
<?php include_once("header.template");?>
        <div id="wrapper">
            <div id="wrapper-inner">
                <div id="sidebar">
                    <div class="box userinfo">
                            <img width="140px" height="140px" src="/show/<?php echo $show;?>" />
                            <div id="user_heart">
                            <a class="<?php echo heart_q($sid)?>" href="fav.php?sid=<?php echo $_GET['id'];?>">
                            <span>heart</span>
                            </a>
                            </div>
                        <div class="userinfo_blk">
                            <h2>
                                <?php echo $name;?>
                            </h2>
                            年级:<?php echo $grade;?><br>
                            院系:<?php echo $branch;?><br />
                            粉丝:<a href="love.php?id=<?php echo $sid;?>"><?php echo $hearts;?></a><br />
							<input type="submit" name="Submit" value="顶 <?php echo $up;?>" id="up" onclick="up();">
							<input type="submit" name="Submit" value="踩 <?php echo $down;?>" id="down" onclick="down();">
                            <br />
                            胜：<?php echo $win;?>&nbsp;&nbsp;负：<?php echo $lose;?>&nbsp;&nbsp;胜率:<?php echo number_format($winper,3)*100;?>%
<script language="javascript"> 
 function up()
 {
  var up=document.getElementById('up');
  up.disabled=true;
  //document.form1.submit();
  window.location.href="updown.php?up=" +<?php echo $sid;?>  ;
  }
 function down()
 {
  var down=document.getElementById('down');
  down.disabled=true;
  //document.form1.submit();
  window.location.href="updown.php?down=" +<?php echo $sid;?>  ;
  }
</script>
                        </div>
                    </div>
                    <div class="operbox">
                        <ul>
                            <li>
                                <a class="i_mail" href="#">
                                    发送消息
                                </a>
                            </li>
                            <div class="clear">
                            </div>
                        </ul>
                        <div class="clear">
                        </div>
                    </div>
					<div class="box">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-4860067162822950";
/* 美女帅哥榜 */
google_ad_slot = "5449427884";
google_ad_width = 200;
google_ad_height = 200;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
                    </div>
                    <div class="box tags">
                    大家的评价：(<a href="tag.php?id=<?php echo $sid;?>" target="_blank">给他评价</a>)<br />
                 	   <ul>
                       <?php
					   $get_tag = "SELECT `tagid`,`tag` FROM `$top_man_tag` WHERE `sid` = $sid ORDER BY `digg` DESC LIMIT 0 , 10 ";
					   $tag_r = mysql_query($get_tag);
					   while($tag = mysql_fetch_row($tag_r))
					   {
					   ?>
            	 			<li>
                             <a href="tag.php?tid=<?php echo $tag[0];?>"><?php echo $tag[1];?></a>
                          </li>
                       <?php
					   }
					   ?>
                        </ul>
                    </div>
                </div>
                <div id="canvas">
                    <div id="content">
                        <div class="pageheader">
                            <h2>
                               <?php echo $name;?>
                            </h2>
                            <div class="right">
                                <ul class="tabs">
                                    <li>
                                        <a href="love.php?id=<?php echo $sid;?>">
                                            粉丝
                                        </a>
                                    </li>
                                    <li class="active">
                                        <a href="#">
                                            留言
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                        <div class="clear">
                        </div>
                        <div id="comments">
<?php
$com_sql = "SELECT I.*,T.`content` FROM `top_comment` I LEFT JOIN `top_comment_content` T ON "; 
$com_sql.= "I.`cid`=T.`cid` WHERE I.`sid`='$sid' ORDER BY I.`time` DESC LIMIT 0,100 ";
$com_result = mysql_query($com_sql);
$i = 1;
if($com_result){

while($com_row = mysql_fetch_row($com_result))
{
	$cid = $com_row[0];
	$com_uid = $com_row[2];
	$com_name = $com_row[3];
	$time = $com_row[4];
	$ip = $com_row[5];
	$content = $com_row[6];
	$count = mysql_query("SELECT count(*) FROM `top_comment`;");
	$count = mysql_fetch_row($count);
	if($i%2 !=0){
		$class = "left";
	}else{
		$class = "right";
	}
	$i++;
?>

<div class="comment"><div class="<?php echo $class;?>"><a href="http://www.fmash.com/?<?php echo $com_uid;?>" ><img class="comment-profile" src="<?php get_avatar($com_uid,small);?>" alt="<?php echo $com_name;?>" /></a></div><div class="<?php echo $class;?>"><div class="comment_title"><a href="http://www.fmash.com/?<?php echo $com_uid;?>" ><?php echo $com_name;?></a> 于<?php echo time2Units($time);?>说    </div><div class="pop"><div class="pop_top_a"><div class="pop_top_b"><div class="pop_top_c"> </div></div></div><div class="pop_body_a"><div class="pop_body_b"><?php echo nl2br("$content");?></div></div><div class="pop_bot_a"><div class="pop_bot_b"><div class="pop_bot_c"> </div></div></div></div></div><div class="clear"></div></div>
<?php
		if(isset($_COOKIE['UID'])){
			if(is_admin($_COOKIE['UID'])){
				echo "<a href=\"admin_del.php?class=comment&cid=".$cid."&from=".$en_url."\" />删除</a>";
			}
		}
	}
}
if(isset($_COOKIE['UID'])&&$_COOKIE['FMASH'] == 'jsuHappynow'){
?>


<div class="comment"><div class="right"><a href="http://www.fmash.com/?<?php echo $uid;?>" ><img class="comment-profile" src="<?php get_avatar($uid,small);?>" alt="<?php echo $username;?>" /></a></div><div class="right"><div class="comment_title"><a href="http://www.fmash.com/?<?php echo $uid;?>" ><?php echo $username;?></a> 添加评论</div><div class="pop"><div class="pop_top_a"><div class="pop_top_b"><div class="pop_top_c"> </div></div></div><div class="pop_body_a"><div class="pop_body_b"><div id="comments_form"><form action="comment.php" method="post"><p><textarea id="cont" name="cont"></textarea></p><p><input type="hidden" name="id" value="<?php echo $sid;?>"/><input type="submit" class="submit" name="commit" value="提交"/></p></form></div></div></div><div class="pop_bot_a"><div class="pop_bot_b"><div class="pop_bot_c"> </div></div></div></div></div><div class="clear"></div></div><?php }else{echo '您需要登录才可以留言以及使用其他功能！';}?></div></div></div><div class="clear"></div></div></div> <?php include_once("footer.template");?>
</body>
</html>